﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using SharedGenomics.Domain;
using SharedGenomics.Workbench.Models;

namespace SharedGenomics.Workbench.Tests.Models
{
    [TestClass]
    public class LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategyTests
    {
        [TestMethod]
        public void ShouldContinueIfMinLinesNotReached()
        {
            LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy strategy = new LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy();
            var result = new AssocAnalysisResult();
            Assert.IsTrue(strategy.ShouldAddAndContinue(result), "ShouldAddAndContinue was false");
        }

        [TestMethod]
        public void ShouldContinueIfEmp1ThresholdNotReached()
        {
            LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy strategy = new LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy();
            var dummyresult = new AssocAnalysisResult();

            for (int i = 0; i < 500; i++)
            {
                strategy.ShouldAddAndContinue(dummyresult);
            }

            Assert.AreEqual(500, strategy.LinesRead);
            var result = new AssocAnalysisResult { Emp1 = 0.0001 };

            Assert.IsTrue(strategy.ShouldAddAndContinue(result), "ShouldAddAndContinue was false");
        }

        [TestMethod]
        public void ShouldNotContinueIfLinesAndEmp1ThresholdPassed()
        {
            LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy strategy = new LineCountOrEmp1ThresholdAnalysisResultsFileReadStrategy();
            var dummyresult = new AssocAnalysisResult();

            for (int i = 0; i < 500; i++)
            {
                strategy.ShouldAddAndContinue(dummyresult);
            }

            Assert.AreEqual(500, strategy.LinesRead);
            var result = new AssocAnalysisResult { Emp1 = 0.4 };

            Assert.IsFalse(strategy.ShouldAddAndContinue(result), "ShouldAddAndContinue was true");
        }
    }
}
